﻿using FiveSister.BAL;
using PMSA.Framework.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Uc_Account_EditUser : System.Web.UI.UserControl
{
    private int userid = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["ui"] != null)
        {
            try
            {
                userid = int.Parse(Request.QueryString["ui"].ToString());
            }
            catch
            {
                CLogManager.Write("User.Edit.PageLoad", "userid not a number: " + Request.QueryString["ui"].ToString(), "ADMIN");
            }
        }
        if (!IsPostBack)
        {
            GetDetailUser(userid);
        }
    }
    private void GetDetailUser(int userid)
    {
        try
        {
            User obj = new User();
            obj = obj.SelectUser(txtUserName.Text, userid);
            txtUserName.Text = obj.UserName;
            txtPassword.Text = obj.Password;
            //cbxIsActive.Checked = obj.IsActive == 1 ? true : false;
        }
        catch (Exception ex)
        {
            CLogManager.Write("Brand.Edit.GetDetailBrand", ex.ToString(), "ADMIN");
        }
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        User obj = new User();
        
        obj = obj.Update(userid, txtUserName.Text, txtPassword.Text, 0);
        if (obj != null)
        {
            Response.Write("<script type='text/javascript'>alert('Edit Successful !');parent.Admin.Account.List.ManipulateData();</script>");
        }
    }
}